function ajax_request(param,callback=new Function){
    // url,type,dataType="json",data=""
    var url = param["url"];
    var type = param["type"] ? param["type"] :"POST";
    var dataType = param["dataType"] ? param["dataType"] :"JSON";
    var data = param["data"] ? param["data"] :"";
    var access_token = param["access_token"] ? param["access_token"] :"";
    console.log(data,type);
    let ajax =
        $.ajax({
            url: url ,
            type: type,
            dataType: dataType,
            data: data,
            beforeSend: function (request) {
                request.setRequestHeader("access_token",access_token);
            },
            success:function(response) {
                if(typeof response == "string"){
                    if(JSON.parse(response)["errcode"] != undefined){
                        if(check_ajax_request(JSON.parse(response)) == false){
                            return;
                        }
                    }
                }else if(typeof response == "object"){
                    if(response["errcode"] != undefined){
                        if(check_ajax_request(response) == false){
                            return;
                        }
                    }
                }
                console.log(typeof response == "string");
                callback(JSON.parse(response));
            },
            error:function(e){
                callback(JSON.parse(response));
            }
        })
}

function check_ajax_request(response){

    if(response["errcode"] >= 200 && response["errcode"] < 4000){
        $.alert('请重新登录', response["errmsg"], function () {
            window.location.href = "login.php";
        });
        return false;
    }
    return true;
}

// 区域名称
function area_name(area_num){
    var text = "";
    if(area_num == "1"){
        text = "广佛版";
    }else if(area_num == "2"){
        text = "粤东版";
    }else if(area_num == "3"){
        text = "粤西版";
    }else if(area_num == "4"){
        text = "钦州版";
    }
    return text;
}

// 倒计时计算
function show_time(element_id, end_time) {
    var time_start = new Date().getTime(); //设定当前时间

    var time_end = new Date(end_time.replace(/-/g , "/")).getTime(); //设定目标时间
    // 计算时间差
    var time_distance = time_end - time_start;
    /*判断活动是否结束*/
    if (time_distance < 0) {

        int_day = "00";
        int_hour = "00";
        int_minute = "00";
        int_second = "00";
    } else {
        // 天
        var int_day = Math.floor(time_distance / 86400000)
        time_distance -= int_day * 86400000;
        // 时
        var int_hour = Math.floor(time_distance / 3600000)
        time_distance -= int_hour * 3600000;
        // 分
        var int_minute = Math.floor(time_distance / 60000)
        time_distance -= int_minute * 60000;
        // 秒
        var int_second = Math.floor(time_distance / 1000)
        // 时分秒为单数时、前面加零

        if (int_day < 10) {
            int_day = "0" + int_day;
        }
        if (int_hour < 10) {
            int_hour = "0" + int_hour;
        }
        if (int_minute < 10) {
            int_minute = "0" + int_minute;
        }
        if (int_second < 10) {
            int_second = "0" + int_second;
        }
    }

    // 显示时间
    $("#" + element_id).text("剩余"+int_day + "天" + int_hour + "时" + int_minute + "分" + int_second + "秒");
    // 设置定时器


    setTimeout("show_time('" + element_id + "','" + end_time + "')", 1000);


}



